package com.itheima.work1120;

import java.util.Collections;
import java.util.Random;
import java.util.TreeSet;

public class Demo1 {
    public static void main(String[] args) {
        TreeSet<Integer> tr = new TreeSet<>();
        Random rand = new Random();
        //需求1
        while (tr.size() < 10) {
            tr.add(rand.nextInt(51));
        }
//        System.out.println(tr);
        //遍历
        for (Integer i : tr) {
            System.out.print(i+ " ") ;
        }

        //需求2
        TreeSet<Integer> tr2 = new TreeSet<>(Collections.reverseOrder());
        while (tr2.size() < 10) {
            tr2.add(rand.nextInt(50,101));
        }
        for (Integer i : tr2) {
            System.out.print(i+ " ") ;
        }


    }


}
